clear all;
clc;

% ------------------------- File Information ------------------------------

phiele = -30;

cd('p1_thresholds');
    
prefix = 'pos_sub_atp_';
suffix = 'act_9um_';
rottag = ['t0p',strrep(num2str(phiele),'-','n')];

dcdata = load([prefix,'dc_',suffix,rottag,'.txt']);
dcth = sort(dcdata(:,1));
drdata = load([prefix,'dr_',suffix,rottag,'.txt']);
drth = sort(drdata(:,1));

cd ..;


frac_dcvsdr = pera_vs_perb(dcth,drth);

% ------------------------- Data Processing -------------------------------

[noaxons,junk] = size(dcdata);

nauc = trapz(frac_dcvsdr(:,1),frac_dcvsdr(:,2))/100;
dr_o = 100*sum( (frac_dcvsdr(:,2) < 0.5) )/noaxons;

% ------------------------- Plotting --------------------------------------

figure;
hold on;
plot(0:100,0:100,'k-','LineWidth',3);
plot(frac_dcvsdr(:,1),frac_dcvsdr(:,2),'k--','LineWidth',3);
hold off;
title(['nAUC = ',num2str(nauc),' and DR_0 = ',num2str(dr_o)]);

return

msub = [1,2:4:noaxons,noaxons];

f_dc = (100/noaxons)*(1:1:noaxons);

figure;
hold on;
plot(0:100,0:100,'k-','LineWidth',3);
plot(f_dc(msub),sel_epi_mu(msub),'k--','LineWidth',3,'MarkerSize',10);
plot(f_dc(msub),sel_sub1_mu(msub),'k.-','LineWidth',2,'MarkerSize',30);
plot(f_dc(msub),sel_sub2_mu(msub),'k^-','LineWidth',2,'MarkerSize',10);
hold off;
ttl = ['Selective Activation of Dorsal Columns (\theta = ',num2str(th_val),'^o)'];
title(ttl,'FontSize',30,'FontWeight','b');
xlabel('Dorsal Columns Activated (%)','FontSize',30);
ylabel('Dorsal Roots Activated (%)','FontSize',30);
L1 = '1 mm above dura';
L2 = '1 mm above cord';
L3 = '1 mm below dura';
legend('No Selectivity',L1,L2,L3,'Location','NW');
set(gca,'FontSize',25);
set(gca,'XTick',0:25:100,'YTick',0:25:100);
axis tight;
axis square;
